<script lang="tsx">
/**
 * 应收退款单
 */
export default {
  name: "income-refund"
}
</script>

<script lang="tsx" setup>
import {ref} from 'vue'
import {definePageModel, PageModel} from "@/frame/view/layout/page-model/constructor.ts"
import OrderForm from "./components/order-form/index.vue"

/**
 * 页面配置
 */
const pageModelRef = ref()
const config = definePageModel<any>({
  url: "/api/IncomeManages",
  otherParams: {
    type: 1
  },
  searchForm: {
    els: [
      {
        eType: 'el-input',
        prop: "code",
        props: {
          placeholder: "单据编码",
          clearable: true
        }
      },
      {
        eType: 'el-input',
        prop: "customer",
        props: {
          placeholder: "客户名称",
          clearable: true
        }
      }
    ]
  },
  table: {
    page: {
      enable: true,
      pageSize: 20
    },
    props: {
      stripe: false,
      border: false
    },
    operation: {
      width: 80,
      props: {
        fixed: "right"
      },
      els: [
        {
          eType: "el-button",
          label: "退款",
          event: "income",
          props: {
            type: "primary",
            link: true
          },
          hide: false
        }
      ]
    },
    els: [
      {
        label: "单据编码",
        prop: "code",
        minWidth: 100
      },
      {
        label: "客户编码",
        prop: "customerCode",
        minWidth: 100
      },
      {
        label: "客户名称",
        prop: "customerName",
        minWidth: 100
      },
      {
        label: "可退金额",
        prop: "incomeDone",
        minWidth: 100
      },
      {
        label: "已退金额",
        prop: "incomeToDo",
        minWidth: 100
      },
      {
        label: "收款凭据",
        prop: "file",
        minWidth: 120
      },
      {
        label: "收款凭据备注",
        prop: "remark",
        minWidth: 120
      },
      {
        label: "退款凭据",
        prop: "returnFile",
        minWidth: 120
      },
      {
        label: "退款凭据备注",
        prop: "returnRemark",
        minWidth: 120
      }
    ]
  }
})

/**
 * 发起收款
 */
const orderFormRef = ref()
const handleIncome = (row: any) => {
  orderFormRef.value.show({
    id: row.id
  })
}

/**
 * 删除
 */
const handleDelete = (row: any) => {
  pageModelRef.value.handleDelete(row)
}

/**
 * 刷新
 */
const handleRefresh = () => {
  pageModelRef.value.refreshTableData()
}

</script>

<template>
  <PageModel ref="pageModelRef" :PageModel="config" @delete="handleDelete"
             @income="handleIncome"
  />

  <OrderForm ref="orderFormRef" @confirm="handleRefresh"/>
</template>